<!DOCTYPE html>
<html lang = "en">
<head>
    <meta charset = "UTF-8">
    <title>Title</title>

    <!--=====================================================================-->
    <script>
        window.onload = function () {
            //点击btn后,text框显示词语
            let oTxt1 = document.getElementById('txt1');
            let oBtn1 = document.getElementById('btn1');

            oBtn1.onclick = function () {
                //oTxt1.value = 'show';

                //oTxt1['value'] = 'show';    // 也可以使用['value'];只要是能用.xxx的地方都可以用['xxx']

                //通过操作dom,使用setAttribute来设置
                oTxt1.setAttribute('value','show'); //与['xxx']一样,只要是能用.xxx的地方都可以用setAttr

                console.log(oTxt1.getAttribute('value'));   //通过getAttr来获取元素,据说99%的情况是用不到的
            }


        }



    </script>
</head>

<body>

<div>
    <input type = "text" value="" id="txt1">
    <input type="button" value="show" id="btn1">

</div>

</body>
</html>